#ifndef MACROS
#define MACROS

#define CGNS_TYPE CG_FILE_HDF5
//#define CGNS_TYPE CG_FILE_ADF

#define STR_LENGTH 64

#define NUM_RESIDS 3

#define D3Q15
//#define D2Q9

#ifdef D2Q9

	#define DIM 2
	#define Q 9

	#define LOAD_E(e) {																									    \
						e[0][0]= 0;e[0][1]= 1;e[0][2]= 0;e[0][3]=-1;e[0][4]= 0;e[0][5]= 1;e[0][6]=-1;e[0][7]=-1;e[0][8]= 1;	\
						e[1][0]= 0;e[1][1]= 0;e[1][2]= 1;e[1][3]= 0;e[1][4]=-1;e[1][5]= 1;e[1][6]= 1;e[1][7]=-1;e[1][8]=-1;	\
					  }

#define LOAD_M(m_tmp) {\
					double m[Q][Q]=\
				   { 1, 1, 1, 1, 1, 1, 1, 1, 1,\
					-4,-1,-1,-1,-1, 2, 2, 2, 2,\
					 4,-2,-2,-2,-2, 1, 1, 1, 1,\
					 0, 1, 0,-1, 0, 1,-1,-1, 1,\
					 0,-2, 0, 2, 0, 1,-1,-1, 1,\
					 0, 0, 1, 0,-1, 1, 1,-1,-1,\
					 0, 0,-2, 0, 2, 1, 1,-1,-1,\
					 0, 1,-1, 1,-1, 0, 0, 0, 0,\
					 0, 0, 0, 0, 0, 1,-1, 1,-1}; \
					 memcpy(m_tmp,m,sizeof(double)*Q*Q);\
					}

#define LOAD_M_INV(m_inv_tmp) {\
						   double m_inv[Q][Q]=\
						   {0.1111111111111111,-0.11111111111111112,  0.1111111111111111,0,0,0,0,0,0,\
							0.1111111111111111,-0.02777777777777779, -0.055555555555555566,0.16666666666666666,-0.16666666666666669,0,0,0.25,0,\
							0.1111111111111111,-0.027777777777777762,-0.055555555555555539,0,-1.3877787807814457e-017,0.16666666666666666,-0.16666666666666669,-0.25,0,\
							0.1111111111111111,-0.02777777777777779, -0.055555555555555566,-0.16666666666666666,0.16666666666666669,0,0,0.25,0,\
							0.1111111111111111,-0.02777777777777779, -0.055555555555555566,0,1.3877787807814457e-017,-0.16666666666666666,0.16666666666666669,-0.25,0,\
							0.1111111111111111, 0.055555555555555552, 0.027777777777777776,0.16666666666666666,0.083333333333333329,0.16666666666666666,0.083333333333333329,0,0.25,\
							0.1111111111111111, 0.055555555555555552, 0.027777777777777776,-0.16666666666666666,-0.083333333333333329,0.16666666666666666,0.083333333333333329,0,-0.25,\
							0.1111111111111111, 0.055555555555555552, 0.027777777777777776,-0.16666666666666666,-0.083333333333333329,-0.16666666666666666,-0.083333333333333329,0,0.25,\
							0.1111111111111111, 0.055555555555555552, 0.027777777777777776,0.16666666666666666,0.083333333333333329,-0.16666666666666666,-0.083333333333333329,0,-0.25};\
							memcpy(m_inv_tmp,m_inv,sizeof(double)*Q*Q);\
                         }

	#define LOAD_OMEGA(omega) {omega[0]=4.0/9.0;omega[1]=1.0/9.0;omega[2]=1.0/9.0;omega[3]=1.0/9.0;omega[4]=1.0/9.0;omega[5]=1.0/36.0;omega[6]=1.0/36.0;omega[7]=1.0/36.0;omega[8]=1.0/36.0;}
	#define LOAD_OPP(opp) {opp[0]=0;opp[1]=3;opp[2]=4;opp[3]=1;opp[4]=2;opp[5]=7;opp[6]=8;opp[7]=5;opp[8]=6;}

	#define NUM_THREADS_DIM_X 32
	#define NUM_THREADS_DIM_Y 16

#endif

#ifdef D3Q15

	#define DIM 3
	#define Q 15

	/*#define LOAD_E(e) {																																												\
						e[0][0]= 0;e[0][1]= 1;e[0][2]=-1;e[0][3]= 0;e[0][4]= 0;e[0][5]= 0;e[0][6]= 0;e[0][7]= 1;e[0][8]=-1;e[0][9]= 1;e[0][10]=-1;e[0][11]= 1;e[0][12]=-1;e[0][13]= 1;e[0][14]=-1;  \
						e[1][0]= 0;e[1][1]= 0;e[1][2]= 0;e[1][3]= 1;e[1][4]=-1;e[1][5]= 0;e[1][6]= 0;e[1][7]= 1;e[1][8]=-1;e[1][9]= 1;e[1][10]=-1;e[1][11]=-1;e[1][12]= 1;e[1][13]=-1;e[1][14]= 1;  \
						e[2][0]= 0;e[2][1]= 0;e[2][2]= 0;e[2][3]= 0;e[2][4]= 0;e[2][5]= 1;e[2][6]=-1;e[2][7]= 1;e[2][8]=-1;e[2][9]=-1;e[2][10]= 1;e[2][11]= 1;e[2][12]=-1;e[2][13]=-1;e[2][14]= 1;  \
					  }*/

	#define LOAD_E(e) {																																												\
						e[0][0]= 0;e[0][1]= 1;e[0][2]=-1;e[0][3]= 0;e[0][4]= 0;e[0][5]= 0;e[0][6]= 0;e[0][7]= 1;e[0][8]=-1;e[0][9]= 1;e[0][10]=-1;e[0][11]= 1;e[0][12]=-1;e[0][13]= 1;e[0][14]=-1;  \
						e[1][0]= 0;e[1][1]= 0;e[1][2]= 0;e[1][3]= 1;e[1][4]=-1;e[1][5]= 0;e[1][6]= 0;e[1][7]= 1;e[1][8]= 1;e[1][9]=-1;e[1][10]=-1;e[1][11]= 1;e[1][12]= 1;e[1][13]=-1;e[1][14]=-1;  \
						e[2][0]= 0;e[2][1]= 0;e[2][2]= 0;e[2][3]= 0;e[2][4]= 0;e[2][5]= 1;e[2][6]=-1;e[2][7]= 1;e[2][8]= 1;e[2][9]= 1;e[2][10]= 1;e[2][11]=-1;e[2][12]=-1;e[2][13]=-1;e[2][14]=-1;  \
					  }

	#define LOAD_M(m_tmp) {\
					   double m[Q][Q]=\
					   { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\
						-2,-1,-1,-1,-1,-1,-1, 1, 1, 1, 1, 1, 1, 1, 1,\
						16,-4,-4,-4,-4,-4,-4, 1, 1, 1, 1, 1, 1, 1, 1,\
						 0, 1,-1, 0, 0, 0, 0, 1,-1, 1,-1, 1,-1, 1,-1,\
						 0,-4, 4, 0, 0, 0, 0, 1,-1, 1,-1, 1,-1, 1,-1,\
						 0, 0, 0, 1,-1, 0, 0, 1, 1,-1,-1, 1, 1,-1,-1,\
						 0, 0, 0,-4, 4, 0, 0, 1, 1,-1,-1, 1, 1,-1,-1,\
						 0, 0, 0, 0, 0, 1,-1, 1, 1, 1, 1,-1,-1,-1,-1,\
						 0, 0, 0, 0, 0,-4, 4, 1, 1, 1, 1,-1,-1,-1,-1,\
						 0, 2, 2,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0,\
						 0, 0, 0, 1, 1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0,\
						 0, 0, 0, 0, 0, 0, 0, 1,-1,-1, 1, 1,-1,-1, 1,\
						 0, 0, 0, 0, 0, 0, 0, 1, 1,-1,-1,-1,-1, 1, 1,\
						 0, 0, 0, 0, 0, 0, 0, 1,-1, 1,-1,-1, 1,-1, 1,\
						 0, 0, 0, 0, 0, 0, 0, 1,-1,-1, 1,-1, 1, 1,-1 };\
						 memcpy(m_tmp,m,sizeof(double)*Q*Q);\
					  }

#define LOAD_M_INV(m_inv_tmp) {\
						   double m_inv[Q][Q]=\
						   {0.066666666666666666,-0.1111111111111111,0.044444444444444446,0,-3.4694469519536142e-018,-2.7755575615628915e-018,2.7755575615628915e-018,2.7755575615628915e-018,6.9388939039072288e-019,6.9388939039072284e-018,7.4014868308343768e-018,0,-3.4694469519536142e-018,0,0,\
                            0.066666666666666666,-0.055555555555555552,-0.01111111111111111,0.10000000000000001,-0.099999999999999978,-3.3306690738754703e-018,2.6367796834847468e-018,3.3306690738754695e-018,8.3266726846886737e-019,0.16666666666666669,7.4014868308343768e-018,2.7755575615628915e-018,-4.1633363423443369e-018,-2.7755575615628915e-018,2.7755575615628915e-018,\
                            0.066666666666666666,-0.055555555555555552,-0.01111111111111111,-0.10000000000000001,0.10000000000000001,-2.2204460492503135e-018,2.9143354396410358e-018,2.2204460492503135e-018,5.5511151231257838e-019,0.16666666666666669,7.4014868308343768e-018,-2.7755575615628919e-018,-2.7755575615628919e-018,2.7755575615628919e-018,-2.7755575615628919e-018,\
                            0.06666666666666668,-0.055555555555555546,-0.01111111111111111,0,0,0.099999999999999992,-0.10000000000000001,5.551115123125783e-018,5.0885221961986346e-018,-0.083333333333333329,0.25,0,-6.9388939039072284e-018,0,0,\
                            0.066666666666666666,-0.055555555555555552,-0.01111111111111111,0,0,-0.10000000000000001,0.10000000000000001,0,3.7007434154171884e-018,-0.083333333333333329,0.25,0,-0,0,0,\
                            0.066666666666666666,-0.055555555555555552,-0.01111111111111111,0,0,-2.220446049250312e-018,-5.5511151231257799e-019,0.10000000000000001,-0.10000000000000001,-0.083333333333333329,-0.25,0,-0,0,0,\
                            0.066666666666666666,-0.055555555555555552,-0.01111111111111111,0,0,-8.881784197001254e-018,-2.2204460492503135e-018,-0.10000000000000001,0.10000000000000001,-0.083333333333333329,-0.25,0,-0,0,0,\
                            0.066666666666666749,0.055555555555555622,0.0027777777777777809,0.10000000000000003,0.025000000000000008,0.10000000000000003,0.025000000000000015,0.10000000000000003,0.025000000000000008,-6.9388939039072284e-018,7.4014868308343861e-018,0.125,0.125,0.125,0.125,\
                            0.06666666666666668,0.055555555555555559,0.0027777777777777775,-0.10000000000000003,-0.025000000000000008,0.10000000000000001,0.025000000000000012,0.10000000000000003,0.025000000000000008,0,7.4014868308343784e-018,-0.125,0.12499999999999997,-0.125,-0.125,\
                            0.06666666666666668,0.055555555555555559,0.0027777777777777775,0.10000000000000001,0.025000000000000001,-0.10000000000000003,-0.024999999999999998,0.10000000000000001,0.025000000000000001,0,7.4014868308343784e-018,-0.125,-0.125,0.125,-0.125,\
                            0.066666666666666638,0.055555555555555525,0.0027777777777777757,-0.10000000000000001,-0.025000000000000001,-0.099999999999999992,-0.024999999999999991,0.10000000000000001,0.025000000000000001,-6.9388939039072284e-018,7.4014868308343738e-018,0.125,-0.125,-0.125,0.125,\
                            0.066666666666666721,0.055555555555555594,0.0027777777777777792,0.10000000000000001,0.025000000000000001,0.099999999999999992,0.025000000000000005,-0.10000000000000003,-0.025000000000000008,0,7.401486830834383e-018,0.125,-0.125,-0.125,-0.125,\
                            0.066666666666666666,0.055555555555555552,0.0027777777777777775,-0.10000000000000001,-0.025000000000000001,0.10000000000000001,0.025000000000000005,-0.10000000000000001,-0.025000000000000001,0,7.4014868308343768e-018,-0.125,-0.125,0.125,0.125,\
                            0.066666666666666693,0.055555555555555573,0.0027777777777777783,0.10000000000000001,0.025000000000000001,-0.10000000000000002,-0.024999999999999998,-0.10000000000000001,-0.025000000000000001,-6.9388939039072284e-018,7.4014868308343799e-018,-0.125,0.125,-0.125,0.125,\
                            0.066666666666666666,0.055555555555555552,0.0027777777777777775,-0.10000000000000001,-0.025000000000000001,-0.10000000000000001,-0.024999999999999998,-0.10000000000000001,-0.025000000000000001,0,7.4014868308343768e-018,0.125,0.125,0.125,-0.125}; \
							memcpy(m_inv_tmp,m_inv,sizeof(double)*Q*Q);\
					}

	#define LOAD_OMEGA(omega) {omega[0]=2.0/9.0;omega[1]=1.0/9.0;omega[2]=1.0/9.0;omega[3]=1.0/9.0;omega[4]=1.0/9.0;omega[5]=1.0/9.0;omega[6]=1.0/9.0;omega[7]=1.0/72.0;omega[8]=1.0/72.0;omega[9]=1.0/72.0;omega[10]=1.0/72.0;omega[11]=1.0/72.0;omega[12]=1.0/72.0;omega[13]=1.0/72.0;omega[14]=1.0/72.0;}
	//#define LOAD_OPP(opp) {opp[0]=0;opp[1]=2;opp[2]=1;opp[3]=4;opp[4]=3;opp[5]=6;opp[6]=5;opp[7]=8;opp[8]=7;opp[9]=10;opp[10]=9;opp[11]=12;opp[12]=11;opp[13]=14;opp[14]=13;}
	#define LOAD_OPP(opp) {opp[0]=0;opp[1]=2;opp[2]=1;opp[3]=4;opp[4]=3;opp[5]=6;opp[6]=5;opp[7]=14;opp[8]=13;opp[9]=12;opp[10]=11;opp[11]=10;opp[12]=9;opp[13]=8;opp[14]=7;}

	#define NUM_THREADS_DIM_X 32
	#define NUM_THREADS_DIM_Y 4
	#define NUM_THREADS_DIM_Z 4

#endif

#endif